查看GitHub仓库大小的几种方法 |
您所在的位置:网站首页 › github 仓库限制 › 查看GitHub仓库大小的几种方法 |
GitHub在默认情况下是不显示仓库大小的,那如果我们要怎样才能查看一个仓库的大小?这篇文章介绍几种方法来实现该功能,总有一种适合你。需要注意的是这里要区分公开仓库和私有仓库。 一、GitHub自带查看仓库大小的功能(public、private)因为这是自带功能,所以公开仓库和私有仓库都可以查看大小。 (以下内容转自:https://blog.csdn.net/i042416/article/details/86666843) 其实github上提供了非常方便的工具供我们查看。 步骤1.登录github网页首页,选择自己账户的settings: 2.点击repository: 3.这里就有每个repository对应的存储空间大小: 只要访问指定网址,即可参看仓库大小,;所以只能访问公开仓库的信息。 语法:https://api.github.com/repos/user/repo,访问后得到一个包含仓库信息(user为用户名,repo为仓库名)的json数据。 如,我的第一个仓库:https://api.github.com/repos/yansheng836/hello-world json数据如下:我们可以看到内容很丰富,其中的size就是仓库大小,单位是kb,其他内容有兴趣也可以了解下。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102{ "id": 159042524, "node_id": "MDEwOlJlcG9zaXRvcnkxNTkwNDI1MjQ=", "name": "hello-world", "full_name": "yansheng836/hello-world", "private": false, "owner": { "login": "yansheng836", "id": 45334066, "node_id": "MDQ6VXNlcjQ1MzM0MDY2", "avatar_url": "https://avatars0.githubusercontent.com/u/45334066?v=4", "gravatar_id": "", "url": "https://api.github.com/users/yansheng836", "html_url": "https://github.com/yansheng836", "followers_url": "https://api.github.com/users/yansheng836/followers", "following_url": "https://api.github.com/users/yansheng836/following{/other_user}", "gists_url": "https://api.github.com/users/yansheng836/gists{/gist_id}", "starred_url": "https://api.github.com/users/yansheng836/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/yansheng836/subscriptions", "organizations_url": "https://api.github.com/users/yansheng836/orgs", "repos_url": "https://api.github.com/users/yansheng836/repos", "events_url": "https://api.github.com/users/yansheng836/events{/privacy}", "received_events_url": "https://api.github.com/users/yansheng836/received_events", "type": "User", "site_admin": false }, "html_url": "https://github.com/yansheng836/hello-world", "description": ":smiley:My first repository. ", "fork": false, "url": "https://api.github.com/repos/yansheng836/hello-world", "forks_url": "https://api.github.com/repos/yansheng836/hello-world/forks", "keys_url": "https://api.github.com/repos/yansheng836/hello-world/keys{/key_id}", "collaborators_url": "https://api.github.com/repos/yansheng836/hello-world/collaborators{/collaborator}", "teams_url": "https://api.github.com/repos/yansheng836/hello-world/teams", "hooks_url": "https://api.github.com/repos/yansheng836/hello-world/hooks", "issue_events_url": "https://api.github.com/repos/yansheng836/hello-world/issues/events{/number}", "events_url": "https://api.github.com/repos/yansheng836/hello-world/events", "assignees_url": "https://api.github.com/repos/yansheng836/hello-world/assignees{/user}", "branches_url": "https://api.github.com/repos/yansheng836/hello-world/branches{/branch}", "tags_url": "https://api.github.com/repos/yansheng836/hello-world/tags", "blobs_url": "https://api.github.com/repos/yansheng836/hello-world/git/blobs{/sha}", "git_tags_url": "https://api.github.com/repos/yansheng836/hello-world/git/tags{/sha}", "git_refs_url": "https://api.github.com/repos/yansheng836/hello-world/git/refs{/sha}", "trees_url": "https://api.github.com/repos/yansheng836/hello-world/git/trees{/sha}", "statuses_url": "https://api.github.com/repos/yansheng836/hello-world/statuses/{sha}", "languages_url": "https://api.github.com/repos/yansheng836/hello-world/languages", "stargazers_url": "https://api.github.com/repos/yansheng836/hello-world/stargazers", "contributors_url": "https://api.github.com/repos/yansheng836/hello-world/contributors", "subscribers_url": "https://api.github.com/repos/yansheng836/hello-world/subscribers", "subscription_url": "https://api.github.com/repos/yansheng836/hello-world/subscription", "commits_url": "https://api.github.com/repos/yansheng836/hello-world/commits{/sha}", "git_commits_url": "https://api.github.com/repos/yansheng836/hello-world/git/commits{/sha}", "comments_url": "https://api.github.com/repos/yansheng836/hello-world/comments{/number}", "issue_comment_url": "https://api.github.com/repos/yansheng836/hello-world/issues/comments{/number}", "contents_url": "https://api.github.com/repos/yansheng836/hello-world/contents/{+path}", "compare_url": "https://api.github.com/repos/yansheng836/hello-world/compare/{base}...{head}", "merges_url": "https://api.github.com/repos/yansheng836/hello-world/merges", "archive_url": "https://api.github.com/repos/yansheng836/hello-world/{archive_format}{/ref}", "downloads_url": "https://api.github.com/repos/yansheng836/hello-world/downloads", "issues_url": "https://api.github.com/repos/yansheng836/hello-world/issues{/number}", "pulls_url": "https://api.github.com/repos/yansheng836/hello-world/pulls{/number}", "milestones_url": "https://api.github.com/repos/yansheng836/hello-world/milestones{/number}", "notifications_url": "https://api.github.com/repos/yansheng836/hello-world/notifications{?since,all,participating}", "labels_url": "https://api.github.com/repos/yansheng836/hello-world/labels{/name}", "releases_url": "https://api.github.com/repos/yansheng836/hello-world/releases{/id}", "deployments_url": "https://api.github.com/repos/yansheng836/hello-world/deployments", "created_at": "2018-11-25T14:52:04Z", "updated_at": "2019-09-22T12:27:48Z", "pushed_at": "2019-09-07T05:34:18Z", "git_url": "git://github.com/yansheng836/hello-world.git", "ssh_url": "[email protected]:yansheng836/hello-world.git", "clone_url": "https://github.com/yansheng836/hello-world.git", "svn_url": "https://github.com/yansheng836/hello-world", "homepage": "https://yansheng836.github.io/hello-world/", "size": 157, "stargazers_count": 0, "watchers_count": 0, "language": "C++", "has_issues": true, "has_projects": true, "has_downloads": true, "has_wiki": true, "has_pages": true, "forks_count": 0, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": { "key": "mit", "name": "MIT License", "spdx_id": "MIT", "url": "https://api.github.com/licenses/mit", "node_id": "MDc6TGljZW5zZTEz" }, "forks": 0, "open_issues": 0, "watchers": 0, "default_branch": "master", "network_count": 0, "subscribers_count": 1} 三、利用浏览器插件:Enhanced GitHub(public、private)该插件在GitHub上开源:https://github.com/softvar/enhanced-github Google商店网址:https://chrome.google.com/webstore/detail/enhanced-github/anlikcnbgdeidpacdbdljnabclhahhmd 下面是官方介绍: 概述显示仓库大小,每个文件的大小,下载链接和复制文件内容的选项,在GitHub网站顶部提供有用功能的扩展。 特征 1.显示仓库规模。 2.显示每个活动分支中的每个文件大小(不适用于文件夹/符号链接) 3.显示每个文件的下载链接(不适用于文件夹/符号链接) 4.直接将文件内容复制到剪贴板(对于markdown文件不起作用) 5.在查看文件内容的同时下载文件。 7.即将推出…请在https://github.com/softvar/enhanced-github/issues上打开一个问题以提出建议 注意:从v1.0.0开始-由于GitHub已停止直接下载文件,因此在按Alt / Cmd(对于Mac)/ Ctrl(对于Windows)时单击下载图标/按钮。 它是开源的-根据MIT许可证 https://github.com/softvar/enhanced-github 注意:私有仓库需要添加Token该插件适用于公开和私有仓库,但是私有仓库需要添加token,不然因为权限不够,会访问不了。 添加token步骤:(详情可见:https://github.com/softvar/enhanced-github#github-api-rate-limiting) 1.先到 https://github.com/settings/tokens ,点击“Generate new token”,范围勾选repo就可以了(如下),拉到最下面,点击“Generatetoken”申请一个token。 2.复制token,然后(右键)点击该插件,选择“选项”,跳转后,等一会儿(10s左右),会弹出如下弹窗,将复制的token填进去,然后去访问一个自己的私有仓库就可以显示大小。 ![]() 谢谢你请我吃糖果 ![]() ![]() |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |